clear all
set	more off

*cd "~/Library/CloudStorage/Dropbox/ors_quality_R01"
cd "~/Dropbox/ors_quality_R01"
use "data/KDG/know_do_gap.dta", clear

*ORS
sum know_ors if sp_type!=1 & prov_type ==1 
gen plot_ors = r(mean) if _n ==1

sum rec_ors if sp_type!=1 & know_ors==1 & prov_type ==1
replace plot_ors = r(mean) if _n ==2

sum know_ors if sp_type!=1 & prov_type ==2 
replace plot_ors = r(mean) if _n ==4

sum rec_ors if sp_type!=1 & know_ors==1 & prov_type ==2
replace plot_ors = r(mean) if _n ==5

sum know_ors if sp_type!=1 & prov_type ==3 
replace plot_ors = r(mean) if _n ==7

sum rec_ors if sp_type!=1 & know_ors==1 & prov_type ==3
replace plot_ors = r(mean) if _n ==8

sum know_ors if sp_type!=1 & prov_type ==4 
replace plot_ors = r(mean) if _n ==10

sum rec_ors if sp_type!=1 & know_ors==1 & prov_type ==4
replace plot_ors = r(mean) if _n ==11

*Antibiotics

recode rec_anti 1=0 0=1
sum know_anti if sp_type!=1 & prov_type ==1 
gen plot_anti = r(mean) if _n ==1

sum rec_anti if sp_type!=1 & know_anti==1 & prov_type ==1
replace plot_anti = r(mean) if _n ==2

sum know_anti if sp_type!=1 & prov_type ==2 
replace plot_anti = r(mean) if _n ==4

sum rec_anti if sp_type!=1 & know_anti==1 & prov_type ==2
replace plot_anti = r(mean) if _n ==5

sum know_anti if sp_type!=1 & prov_type ==3 
replace plot_anti = r(mean) if _n ==7

sum rec_anti if sp_type!=1 & know_anti==1 & prov_type ==3
replace plot_anti = r(mean) if _n ==8

sum know_anti if sp_type!=1 & prov_type ==4 
replace plot_anti = r(mean) if _n ==10

sum rec_anti if sp_type!=1 & know_anti==1 & prov_type ==4
replace plot_anti = r(mean) if _n ==11

	

	replace plot_ors = plot_ors*100
	replace plot_anti = plot_anti*100

	gen full = 100 if _n==1|_n==2|_n==4|_n==5|_n==7|_n==8|_n==10|_n==11
	
gen axis = _n if _n<=11

twoway(bar full axis if _n==1 | _n==4|_n==7|_n==10, color(blue*.1) barwidth(.6)) ///
(bar full axis if _n==2 | _n==5 | _n==8| _n==11 , color(red*.1) barwidth(.6)) ///
(bar plot_ors axis if _n==1 | _n==4|_n==7|_n==10, color(blue*.4) barwidth(.6)) ///
(bar plot_ors axis if _n==2 | _n==5 | _n==8| _n==11, color(red*.4) barwidth(.6)) , ///
xlabel(1.5 "MBBS" 4.5 "RMP" 7.5 "AYUSH" 10.5 "Pharmacy", notick) ///
ylabel(0(10)100, grid gstyle(dot)) ///
legend(order(3 "Correct knowledge" 4 "Correct treatment (if correct knowledge)" 1 "Know gap" 2 "Know-do gap")) ///
xtitle(" ") ///
ytitle("%")

graph export "figures/know_do_figure_prov_type_ors.pdf", replace


twoway(bar full axis if _n==1 | _n==4|_n==7|_n==10, color(blue*.1) barwidth(.6)) ///
(bar full axis if _n==2 | _n==5 | _n==8| _n==11 , color(red*.1) barwidth(.6)) ///
(bar plot_anti axis if _n==1 | _n==4|_n==7|_n==10, color(blue*.4) barwidth(.6)) ///
(bar plot_anti axis if _n==2 | _n==5 | _n==8| _n==11, color(red*.4) barwidth(.6)) , ///
xlabel(1.5 "MBBS" 4.5 "RMP" 7.5 "AYUSH" 10.5 "Pharmacy", notick) ///
ylabel(0(10)100, grid gstyle(dot)) ///
legend(order(3 "Correct knowledge" 4 "No Abx Prescription (if correct knowledge)" 1 "Know gap" 2 "Know-do gap") size(small)) ///
xtitle(" ") ///
ytitle("%")

graph export "figures/know_do_figure_prov_type_anti.pdf", replace
 
